<template>
  <div>
    <h2>Abc组件-按钮和输入框互斥效果</h2>
    <input type="text" v-if="flag" @blur="flag = false" ref="ipt" />
    <button v-else @click="showIpt">按钮</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: true,
    };
  },
  methods: {
    showIpt() {
      this.flag = true;
      this.$nextTick(() => {
        this.$refs.ipt.focus(); //让输入框获取焦点
      });
    },
  },
};
</script>

<style>
</style>